
// class my_env extends uvm_env

//   drv = my_driver::type_id::create("my_drv", this);

//   virtual task main_phase(arguments);

// endclass
// module top_tb;

// initial begin
//   //uvm_config_db#(virtual my_if)::set(null, "uvm_test_top.my_drv", "vif", inpu t_if);
// end
// endmodule


class my_env extends uvm_env;
    //my_driver drv;
    //my_monitor o_mon;

    my_agent i_agent;
    my_agent_out o_agent;

    //参考模型
    my_model mdl;
    //
    my_scoreboard sco;
    
    function new(string name = "my_env", uvm_component parent);
        super.new(name, parent);
    endfunction

   virtual function void build_phase(uvm_phase phase);
     super.build_phase(phase);
    //  drv = my_driver::type_id::create("drv", this);
    //  o_mon = my_monitor::type_id::create("o_mon", this);

     i_agent = my_agent::type_id::create("i_agent", this);
     o_agent = my_agent_out::type_id::create("o_agent", this);
     i_agent.is_active = UVM_ACTIVE;
     o_agent.is_active = UVM_PASSIVE;

     sco = my_scoreboard::type_id::create("sco", this);

     mdl = my_model::type_id::create("mdl", this);

     uvm_config_db#(uvm_object_wrapper)::set(this,
                                      "i_agent.sqr.main_phase",
                                      "default_sequence",
                                      my_sequence::type_id::get());//default sequence
   endfunction

   extern virtual task main_phase(uvm_phase phase);
   extern virtual function void connect_phase(uvm_phase phase);
   
   `uvm_component_utils(my_env)
endclass

task my_env::main_phase(uvm_phase phase);
    super.main_phase(phase);

//启动seq
    // my_sequence seq;
    // seq = my_sequence::type_id::create("seq", this);
    // seq.start(i_agent.sqr);
endtask

function void my_env::connect_phase(uvm_phase phase);
    super.connect_phase(phase);

    //i_agent.A_port.connect(o_agent.B_export);
    i_agent.info_data_put_port.connect(mdl.model_receive);
    mdl.model_transmit.connect(sco.code_from_model);

    sco.code_from_dut.connect(o_agent.code_data_get_export);

endfunction



